<table width="1024" align="center" class="borda">
    <tr>
        <td>Digite a descrição para busca:
            <form id="form1" name="form1" method="post" action="?menu=visualizar_requisicao">
                <label>
                    <input type="text" size="60" name="texto" id="texto" />
                </label>
                <label> </label>
                <input type="submit" name="buscar" id="buscar"  value="Buscar" />
            </form></td>
    </tr>
    <tr>
        <td height="120">
            <?php
            $desc = $_POST['texto'];
            if (isset($desc)) {
                require_once '../dao/RequisicaoDaoImp.class.php';
                $dao = new RequisicaoDaoImp();
                $result = $dao->buscarDescricao($desc);
            ?>
                <table width='1024' border="1">
                    <tr>
                        <th> ID </th>
                        <th>Número de Inscrição </th>
                        <th colspan="3"> Operações</th>
                    </tr>
                <?php
                foreach ($result as $row) {
                ?>
                    
                    <tr>
                        <td><?php echo $row['idRequisicao'] ?> </td>
                        <td><?php echo $row['NumeroInscricao'] ?> </td>
                        <!-- func =  1 indica cadastrar, func = 2 indica alterar e 3 indica deletar e 4 visualizar-->
                        <td><a href="?menu=visualizar_requisicao&func=1&id=<?php echo $row['idRequisicao'] ?>">Visualizar</a> </td>
                        <td><a href="?menu=visualizar_requisicao&func=2&id=<?php echo $row['idRequisicao'] ?>">Alterar</a> </td>
                        <td><a href="?menu=visualizar_requisicao&func=3&id=<?php echo $row['idRequisicao'] ?>">Deletar</a> </td>


                    </tr>
                <?php
                }
                ?>
            </table>
            <?php
            }
            ?>
        </td>
    </tr>

</table>
<table width="1024" align="center" class="borda">
    <?php
            $acao = $_GET['func'];
            $id = $_GET['id'];
            if (isset($acao) && isset($id)) {

                require_once '../dao/RequisicaoDaoImp.class.php';
                $dao = new RequisicaoDaoImp();
                $result = $dao->buscarId($id);
    ?>
                <form name="form1" method="post" action="pages/daoRequisicao.php">
                    <input name="acao" id="acao" type="hidden" value="<?php echo $acao; ?>" />
                    <table width="1024" border="0" align="center">
<?php
                foreach ($result as $row) {
?>

                    <tr>
                        <td width="187" height="43" align="right">C&oacute;digo</td>
                        <td width="827" ><label>
                                <input name="id" type="text" id="id" value="<?php echo $row['idRequisicao'] ?>" width="50" />
                            </label></td>
                    </tr>
                    <tr>
                        <td width="187" height="43" align="right">Número de Inscrição</td>
                        <td width="827" ><label>
                                <input name="numero" type="text" id="nome" value="<?php echo $row['NumeroInscricao'] ?>" width="400" />
                            </label></td>
                    </tr>
                    <tr>
                        <td height="43" align="right">Descricao</td>
                        <td ><label>
                                <input name="descricao" type="text" value="<?php echo $row['descricao']; ?>" />
                            </label>
                            </td>
                    </tr>
                    <tr>
                        <td height="43" align="right">Imagem</td>
                        <td ><label>
                                <?php
                                    if($acao == 1){?>
                                        <input name="imagem" type="text" value="<?php echo $row['imagemUrl']; ?>"/>
                                    <?php
                                    }else{
                                        ?>
                                        <input name="imagem" type="file"  value="<?php echo $row['imagemUrl']; ?>"/>
                                        <?php
                                    }?>
                            </label></td>
                    </tr>
                    
                    <tr>
                        <td>
<?php
                    switch ($acao) {
                        case 2: {
                                echo "<input type='submit' value='Alterar' />";
                                break;
                            }
                        case 3: {
                                echo "<input type='submit' value='Deletar' />";
                                break;
                            }
                        default:break;
                    }
?>

                </td>
            </tr>

<?php
                }
?>

        </table>
    </form>
<?php
            }
?>
</table>